var permute = function(nums) {
        const res = [], path = [];
        backtracking(nums, nums.length, []);
        return res;
        
        function backtracking(n, k, used) {
            if(path.length === k) {
                res.push(Array.from(path));
                return;
            }
            for (let i = 0; i < k; i++ ) {
                if(used[i]) continue;
                path.push(n[i]);
                console.log(path,'2')
                used[i] = true; // 同支
                backtracking(n, k, used);
                console.log(path,'2')
                console.log(path,'3')
                path.pop();
                used[i] = false;
            }
        }
    };
    permute([1,2,3])